package com.crm.customers.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.crm.base.dao.BaseDao;
import com.crm.customers.dao.ContactsDynamicInfoDao;
import com.crm.customers.model.ContactsDynamicInfo;

@Repository("contactsDynamicInfoDao")
public class ContactsDynamicInfoDaoImpl extends BaseDao implements ContactsDynamicInfoDao {

	private static final String MAPPER_NAMESPACE = "ContactsDynamicInfoMapper.";
	
	@Override
	public ContactsDynamicInfo insertContactsDynamicInfo(
			ContactsDynamicInfo cdinfo) {
		insert(MAPPER_NAMESPACE+"insertContactsDynamicInfo", cdinfo);
		return cdinfo;
	}

	@Override
	public int updateContactsDynamicInfoState(ContactsDynamicInfo cdinfo) {
		return update(MAPPER_NAMESPACE+"updateContactsDynamicInfoState", cdinfo);
	}

	@Override
	public List<ContactsDynamicInfo> getContactsDynamicInfo(ContactsDynamicInfo cinfo) {
		List<ContactsDynamicInfo> list = selectList(MAPPER_NAMESPACE+"getContactsDynamicInfo", cinfo);
		if (list != null && list.size() > 0) {
			list.get(0).setTotalResults((Integer)selectOne(MAPPER_NAMESPACE+"getContactsDynamicInfoCount", cinfo));
		}
		return list;
	}

	@Override
	public List<ContactsDynamicInfo> getContactsDynamicInfoList(ContactsDynamicInfo cdinfo) {
		List<ContactsDynamicInfo> list = selectList(MAPPER_NAMESPACE+"getContactsDynamicInfoList", cdinfo);
		if (list != null && list.size() > 0) {
			list.get(0).setTotalResults((Integer)selectOne(MAPPER_NAMESPACE+"getContactsDynamicInfoListCount", cdinfo));
		}
		return list;
	}

	@Override
	public int getContactsDynamicInfoByTime(ContactsDynamicInfo cdinfo) {
		return selectOne(MAPPER_NAMESPACE+"getContactsDynamicInfoByTime", cdinfo);
	}

	@Override
	public int getCustomerTouchCount(ContactsDynamicInfo cdinfo) {
		return selectOne(MAPPER_NAMESPACE+"getCustomerTouchCount", cdinfo);
	}

	@Override
	public int getCustomerEnteringCount(ContactsDynamicInfo cdinfo) {
		return selectOne(MAPPER_NAMESPACE+"getCustomerEnteringCount", cdinfo);
	}

	@Override
	public List<ContactsDynamicInfo> getAllcdinfoList(ContactsDynamicInfo cdinfo) {
		List<ContactsDynamicInfo> list = selectList(MAPPER_NAMESPACE+"getAllcdinfoList", cdinfo);
		if (list != null && list.size() > 0) {
			list.get(0).setTotalResults((Integer)selectOne(MAPPER_NAMESPACE+"getAllcdinfoListCount", cdinfo));
		}
		return list;
	}

}
